import React from 'react'
import {BrowserRouter as Router,Route,Link,Routes}from 'react-router-dom'   //(npm install react-router-dom)


const Main=()=>{
    return (
        <div>
            <h3>我是首页哦</h3>
            <ul>
            <li><Link to="/register">注册</Link></li>
            </ul>
            <Routes>
            <Route path="/register"  exact element={<Register />} />
            </Routes>
        </div>
    )
}
const Login=()=>(
    <div>
        <p>我是登录页面</p>
        <input type='text' />
        <button>登录</button>
    </div>
)
const Register=()=>(
    <div>
        <p>我是注册页面</p>
        <input type='text' />
        <button>注册</button>
    </div>
)
const App=()=>(
            <Router>
                <h1>路由测试</h1>
                <ul>
                    <li><Link to="/main">首页</Link></li>
                    <li><Link to="/login">去登录</Link></li>
                </ul>
                <Routes>
                <Route path="/login" element={<Login/>}></Route>
                <Route path="/main" element={<Main/>}></Route>
                </Routes>
            </Router>
    )
    
export default App